#ifdef __MMI_DSM_NEW__

#include "MMI_Include.h"
#include "ProfilesAppGprot.h"
#include "AlarmDef.h"
#include "SSCStringHandle.h"
#include "ProfilesSrv.h"
#include "WPSSProtos.h"
#include "app_str.h"
#include "FileMgrType.h"
#include "app_str.h"
#include "DtcntSrvGprot.h"
#include "mrp_include.h"

#include "mmi_rp_app_worldclock_def.h"

#define FMGR_MAX_FILE_LEN           (MAX_SUBMENU_CHARACTERS)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int32 mr_setting_set_wallpaper(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
#if 0
	int32 ret;
	U16 fullpathname[DSM_MAX_FILE_LEN] ={0};
	S16 error;
	extern PHNSET_CNTX *g_phnset_cntx_p;
	extern PHNSET_WPSS_FILENAME_STRUCT phnset_wpss_filename;
	extern void SetIdleScreenWallpaperName(UI_string_type name);
	mr_wallpaper_info_t *req = ( mr_wallpaper_info_t*)input;
	if(req == NULL||input_len == 0||req->filename == NULL)
		return MR_FAILED;

	mr_fs_get_filename((char *)fullpathname,(char *)req->filename);
	ret = mr_info((char *)req->filename);

	if(ret != MR_IS_FILE) 
		return MR_FAILED;
	
	if(req->setType == MR_IDLE_BG_PAPER) 
	{
#if (MTK_VERSION >= 0x0852)
		g_phnset_cntx_p->wpss_type = MMI_PHNSET_TYPE_WP;
		mr_setting_theme_set_wallpaper_and_screensaver((S8*)fullpathname);
#else	
		g_phnset_cntx_p->isCorrectSet = 1;
		g_phnset_cntx_p->curtWpID =  0;
		g_phnset_cntx_p->isShort  = 0;
		phnset_wpss_filename.isWPShort = 0; /*表示是unicode编码*/
		
		mmi_ucs2cpy((S8 *)phnset_wpss_filename.wallpaper, (S8*)fullpathname);
		mmi_dispchar_set_img_id(NVRAM_FUNANDGAMES_SETWALLPAPER, &(g_phnset_cntx_p->curtWpID));
		WriteRecord( NVRAM_EF_WPSS_FILENAME_LID, 1, &phnset_wpss_filename, sizeof(phnset_wpss_filename), &error );
		SetIdleScreenWallpaperName((UI_string_type)phnset_wpss_filename.wallpaper);
		//wgui_save_wallpaper_to_speedup();	
#endif		
		return MR_SUCCESS;
	}
	else if(req->setType == MR_IDLE_SAVER_PAPER)
	{
		g_phnset_cntx_p->curSsID = 0;
		g_phnset_cntx_p->isShort  = 0;

		g_phnset_cntx_p->curSSStatus = 1;
		WriteValue(NVRAM_SCREENSAVER_STATUS, &(g_phnset_cntx_p->curSSStatus), DS_BYTE, &error);
		g_phnset_cntx_p->curSSWaitTime = 5;
		WriteValue(NVRAM_SCREENSAVER_WAITING, &(g_phnset_cntx_p->curSSWaitTime), DS_BYTE, &error);
#if (MTK_VERSION >= 0x0852)
		g_phnset_cntx_p->wpss_type = MMI_PHNSET_TYPE_SS;
		mr_setting_theme_set_wallpaper_and_screensaver((S8*)fullpathname);
#else
		phnset_wpss_filename.isSSShort = 0; /*表示是unicode编码*/
		mmi_ucs2cpy((S8 *)phnset_wpss_filename.screensave, (S8*)fullpathname);
		mmi_dispchar_set_img_id(NVRAM_CURRENT_SCREENSVER_ID, &(g_phnset_cntx_p->curSsID));
		WriteRecord( NVRAM_EF_WPSS_FILENAME_LID, 1, &phnset_wpss_filename, sizeof(phnset_wpss_filename), &error );
#endif		
		g_phnset_cntx_p->isCorrectSet = 1;
		return MR_SUCCESS;
	}
	else
	{
		return MR_FAILED;
	}
	return MR_FAILED;
#else
	mr_wallpaper_info_t* req = ( mr_wallpaper_info_t*)input;
	U16 fullpathname[DSM_MAX_FILE_LEN] ={0};

	if(req == NULL || input_len == 0 || req->filename == NULL)
		return MR_FAILED;

	mr_fs_get_filename((char*)fullpathname, (char*)req->filename);
	
	if (req->setType == MR_IDLE_BG_PAPER)
	{
#if 1	
extern int32 mr_setting_wallpaper_adp(int16* path);

		if (mr_setting_wallpaper_adp(fullpathname))
			return MR_SUCCESS;
		else
			return MR_FAILED;
#else
		PhnsetSetWallpaperByFileName((S8*)fullpathname);
#endif		
		return MR_SUCCESS;
	}
	else if (req->setType == MR_IDLE_SAVER_PAPER)
	{
#if 1	
extern int32 mr_setting_screensaver_adp(int16* path);

		if (mr_setting_screensaver_adp(fullpathname))
			return MR_SUCCESS;
		else
			return MR_FAILED;
#else
		PhnsetSetScrSvrByFileName((S8*)fullpathname);
#endif		
		return MR_SUCCESS;
	}
	else
	{
		return MR_FAILED;
	}
#endif
}


int32 mr_setting_set_ring(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	T_DSM_RING_SET* ringSet = (T_DSM_RING_SET*)input;
		
#ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
	int slotid = 0;
       U16 fullpathname[DSM_MAX_FILE_LEN] = {0};
	PMG_ADDFILE_ERRNO err = PMG_ADDFILE_ERR_UNKNOWN;
	BOOL isExist =FALSE;

	if(ringSet == NULL)
		return MR_FAILED;
		
	mr_fs_get_filename((char *)fullpathname, (char *)ringSet->path);

	slotid = PmgGetSlotByPathFileName((S8 *)fullpathname);
	
	if(slotid != PMG_INVAILD_SLOT)
	{
		isExist = TRUE;
		err = PMG_ADDFILE_ERR_SUCCESS;
	}
	
	if(!isExist)
	{
		for(slotid= 0;slotid < MAXIMUM_EXT_MELODY_NUM;slotid++)
		{
			if(PmgIsEmptySlot(slotid))
				break;
		}	

		if(slotid == MAXIMUM_EXT_MELODY_NUM)
			slotid = MAXIMUM_EXT_MELODY_NUM-1;

		if( PmgCheckImyMidFileSize((S8*)fullpathname) == PMG_ADDFILE_ERR_FILE_TOO_LARGE )
	       {
			err = PMG_ADDFILE_ERR_FILE_TOO_LARGE;
	       }
		else
		{
			PmgSetShortFileName( FALSE );
			
			if(PmgIsEmptySlot(slotid) == MMI_FALSE)
				err = PmgReplaceExtMelodyBySlotPathFileName((S8*) fullpathname , slotid);
			else
				err = PmgAddExtMelodyBySlotPathFileName((S8*) fullpathname , slotid);
		}
	}
	
	if(err== PMG_ADDFILE_ERR_SUCCESS)
	{
		S16 ret = 0;
		extern U8 gprofileId;				
		switch(ringSet->scene)
		{
			case MR_SCENE_NORMAL:
				gprofileId = MMI_PROFILE_GENERAL;
				break;
			case MR_SCENE_MEETING:
				gprofileId = MMI_PROFILE_MEETING;
				break;
			case MR_SCENE_INDOOR:
				gprofileId = MMI_PROFILE_INDOOR;
				break;
			case MR_SCENE_OUTDOOR:
				gprofileId = MMI_PROFILE_OUTDOOR;
				break;
			default:
				return MR_FAILED;
		}
		
		if(ringSet->type == MR_CALL_RING)
		{
#ifdef __MMI_DUAL_SIM_MASTER__
#ifdef __MMI_DUAL_PROFILE_SUPPORT__
			if(dsmDualSim.simId[dsmDualSim.curActive] == DSM_SLAVE_SIM)
			       ret = SetCard2RingToneID( (U16)(PMG_EXT_MELODY_BEGIN+slotid) );
			else
#endif
#endif
				ret = SetRingToneID( (U16)(PMG_EXT_MELODY_BEGIN+slotid) );
		}
		else if(ringSet->type == MR_ALARM_RING)
		{
#ifndef __MMI_ALM_CUSTOMIZE_TONE__					
			ret = SetAlarmToneID( (U16)(PMG_EXT_MELODY_BEGIN+slotid) );
#else
			g_alm_cntx.AlmList[0].AudioOption = ALM_AUDIO_OPTIONS_TONE;
			g_alm_cntx.AlmList[0].AudioOptionValue = PMG_EXT_MELODY_BEGIN+slotid;
			AlmWriteToNvram();
			ret = 0;
#endif
		}
		else if(ringSet->type == MR_SMS_RING)
		{
#if (MTK_VERSION > 0x0828) //huangsunbo 20100305 for 23D 08A0828
			mmi_profiles_tone_struct tonesetup;
#else
			TONE_SETUP tonesetup;
#endif
		
			tonesetup.messageTone= (U16)(PMG_EXT_MELODY_BEGIN+slotid);
			
#ifdef __MMI_DUAL_SIM_MASTER__
#ifdef __MMI_DUAL_PROFILE_SUPPORT__  
			if(dsmDualSim.simId[dsmDualSim.curActive] == DSM_SLAVE_SIM)					
				{
				tonesetup.card2_messageTone = (U16)(PMG_EXT_MELODY_BEGIN+slotid);
				ret =SetCard2MessageToneType(tonesetup);
				}
			else
#endif
#endif	
#if (MTK_VERSION > 0x0828) //huangsunbo 20100305 for 23D 08A0828
			ret = SetMessageToneType(tonesetup, MMI_PROFILE_MESSAGE_TYPE_SMS);
#else
			ret = SetMessageToneType(tonesetup);
#endif

		}
		else
			ret = -1;
		if(ret == 0 )
			return MR_SUCCESS;
		else
			return MR_FAILED;
	}
	else
	{
		return MR_FAILED;
	}
#else
	srv_prof_settings_enum prof_settings;
	WCHAR fullpathname[DSM_MAX_FILE_LEN] = {0};
	srv_prof_ret ret;
	int32 active_sim;

	if(ringSet == NULL)
		return MR_FAILED;
		
	mr_fs_get_filename((char*)fullpathname, (char*)ringSet->path);

	active_sim = mr_sim_get_active();

	if (ringSet->type == MR_CALL_RING)
	{
		if (active_sim == DSM_SLAVE_SIM)
		{
			prof_settings = SRV_PROF_SETTINGS_MT_CALL_CARD2_TONE;
		}
		else if (active_sim == DSM_THIRD_SIM)
		{
			prof_settings = SRV_PROF_SETTINGS_MT_CALL_TONE + 2;	// SRV_PROF_SETTINGS_MT_CALL_CARD3_TONE
		}
		else if (active_sim == DSM_THIRD_SIM)
		{
			prof_settings = SRV_PROF_SETTINGS_MT_CALL_TONE + 3;	// SRV_PROF_SETTINGS_MT_CALL_CARD4_TONE
		}
		else
		{
			prof_settings = SRV_PROF_SETTINGS_MT_CALL_TONE;
		}
	}
	else if (ringSet->type == MR_SMS_RING)
	{
		if (active_sim == DSM_SLAVE_SIM)
		{
			prof_settings = SRV_PROF_SETTINGS_SMS_CARD2_TONE;
		}
		else if (active_sim == DSM_THIRD_SIM)
		{
			prof_settings = SRV_PROF_SETTINGS_SMS_TONE + 2;	// SRV_PROF_SETTINGS_SMS_CARD3_TONE
		}
		else if (active_sim == DSM_THIRD_SIM)
		{
			prof_settings = SRV_PROF_SETTINGS_SMS_TONE + 3;	// SRV_PROF_SETTINGS_SMS_CARD4_TONE
		}
		else
		{
			prof_settings = SRV_PROF_SETTINGS_SMS_TONE;
		}
	}
	else if (ringSet->type == MR_ALARM_RING)
	{
		prof_settings = SRV_PROF_SETTINGS_ALERT_TYPE;
	}
	else
	{
		return MR_FAILED;
	}

	ret = srv_prof_set_current_profile_tone_with_file_path(prof_settings, fullpathname);
	kal_prompt_trace(MOD_MMI, "sky:mr_setting_set_ring ret=%d", ret);
	if (ret == SRV_PROF_RET_SUCCESS || ret == SRV_PROF_RET_EXT_MELODY_REPLACED)
		return MR_SUCCESS;
	else
		return MR_FAILED;
#endif
}


int32 mr_setting_set_theme(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
#ifdef __MMI_DSM_THEME__
	mr_theme_info_t *req = (mr_theme_info_t *)input;
	char fullpathname[DSM_MAX_FILE_LEN] ={0};
	if(req == NULL)
		return MR_FAILED;
	sprintf(fullpathname,"%c:\\%s\\%s", mr_fs_get_work_drv(), mr_fs_get_work_path(), req->folder);

	if (dsmSetTheme(fullpathname, req->themeid) == DSM_THEME_SUCCESS)
		return MR_SUCCESS;
	else
		return MR_FAILED;
#else
	return MR_IGNORE;
#endif
}


int32 mr_setting_restore_theme(int32 param)
{
#ifdef __MMI_DSM_THEME__
	dsmThemeRestore();
	if(dm_get_scr_bg_layer()>0)
	{
		dm_draw_scr_bg_image();
	}
	return MR_SUCCESS;
#else
	return MR_IGNORE;
#endif
}


int32 mr_setting_get_active_theme_id(int32 param)
{
#ifdef __MMI_DSM_THEME__
	int32 id = dsmGetActiveThemeId();
	return id == 0? MR_FAILED : id + MR_PLAT_VALUE_BASE;
#else
	return MR_FAILED;
#endif
}


int32 mr_setting_set_theme_mainmenu_index(int32 index)
{
	extern int gThemeMainmenuIndex;
	gThemeMainmenuIndex = index;
	return MR_SUCCESS;
}


int32 mr_setting_get_cur_scene(int32 param)
{
	int32 scene;

	switch (srv_prof_get_activated_profile())
	{
	case MMI_PROFILE_GENERAL:
		scene = MR_SCENE_NORMAL;
		break;

	case MMI_PROFILE_MEETING:
		scene = MR_SCENE_MEETING;
		break;

	case MMI_PROFILE_OUTDOOR:
		scene = MR_SCENE_OUTDOOR;
		break;

	default:
		scene = MR_SCENE_MUTE;
		break;
	
	}

	return scene + MR_PLAT_VALUE_BASE;	
}



int32 mr_setting_check_wifi_support(int32 param)
{
#if defined(__MMI_DSM_WIFI_SUPPORT__) && defined(__WIFI_SUPPORT__)
	/*如果wifi处于关闭的状态的话，也是返回MR_FAILED*/
	if (srv_dtcnt_wlan_status() == SRV_DTCNT_WLAN_STATUS_CONNECTED)
	{
		return MR_SUCCESS;
	} else
#endif
	return MR_FAILED;
}


int32  mr_setting_wifi_switch(int32 s)
{
#ifdef __MMI_DSM_WIFI_SUPPORT__
	extern BOOL isDsmVIAWIFI;
	isDsmVIAWIFI = s? TRUE : FALSE;
	return MR_SUCCESS;
#else
	return MR_IGNORE;
#endif
}


int32 mr_setting_wifi_exist(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
//是否存在WIFI功能
#ifdef __WIFI_SUPPORT__
	return MR_SUCCESS;
#else
	return MR_FAILED;
#endif
}


int32 mr_setting_get_screen_type(int32 param)
{
#ifdef  __MMI_TOUCH_SCREEN__
#ifdef __MMI_REDUCED_KEYPAD__//todo,huangsunbo 20120202
	return MR_ONLY_TOUCH_SCREEN;
#else
	return MR_TOUCH_SCREEN;
#endif
#else
	return MR_NORMAL_SCREEN;
#endif

}


int32 mr_setting_get_applist_title(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	if(output == NULL||output_len == NULL)
		return MR_FAILED;
	*output = (uint8 *)MR_APPLIST_TITLE;
	*output_len = strlen(MR_APPLIST_TITLE);
	return MR_SUCCESS;
}


int32 mr_setting_get_font_info(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	static int32 wordInfo = (__MR_CFG_VAR_ENWORD_H__<<24 ) |(__MR_CFG_VAR_ENWORD_W__<<16) |(__MR_CFG_VAR_CHWORD_H__<<8 ) |(__MR_CFG_VAR_CHWORD_W__) ;

	if(output == NULL||output_len== NULL)
		return MR_FAILED;

	*output = (unsigned char*)&wordInfo;
	*output_len = 4;
	return MR_SUCCESS;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////

static const char* s_support_langs_ssc[] = {
#if defined(__MMI_LANG_ENGLISH__)		
	SSC_ENGLISH,
#endif
#if defined(__MMI_LANG_TR_CHINESE__)		
	SSC_TCHINESE, 
#endif
#if defined(__MMI_LANG_SPANISH__)
	SSC_SPANISH, 
#endif
#if defined(__MMI_LANG_DANISH__)
	SSC_DANISH, 
#endif
#if defined(__MMI_LANG_POLISH__)
	SSC_POLISH,
#endif
#if defined(__MMI_LANG_FRENCH__)
	SSC_FRENCH, 
#endif
#if defined(__MMI_LANG_GERMAN__)
	SSC_GERMAN, 
#endif
#if defined(__MMI_LANG_ITALIAN__)
	SSC_ITALIAN, 
#endif
#if defined(__MMI_LANG_THAI__)
	SSC_THAI, 
#endif
#if defined(__MMI_LANG_RUSSIAN__)
	SSC_RUSSIAN,
#endif
#if defined(__MMI_LANG_BULGARIAN__)
	SSC_BULGARIAN, 
#endif
#if defined(__MMI_LANG_UKRAINIAN__)
	SSC_UKRAINIAN, 
#endif
#if defined(__MMI_LANG_PORTUGUESE__)
	SSC_PORTUGUESE, 
#endif
#if defined(__MMI_LANG_TURKISH__)
	SSC_TURKISH, 
#endif
#if defined(__MMI_LANG_VIETNAMESE__)
	SSC_VIETNAMESE, 
#endif
#if defined(__MMI_LANG_INDONESIAN__)
	SSC_INDONESIAN, 
#endif
#if defined(__MMI_LANG_CZECH__)
	SSC_CZECH, 
#endif
#if defined(__MMI_LANG_MALAY__)
	SSC_MALAY, 
#endif
#if defined(__MMI_LANG_FINNISH__)
	SSC_FINNISH, 
#endif
#if defined(__MMI_LANG_HUNGARIAN__)
	SSC_HUNGARIAN, 
#endif
#if defined(__MMI_LANG_SLOVAK__)
	SSC_SLOVAK, 
#endif
#if defined(__MMI_LANG_DUTCH__)
	SSC_DUTCH, 
#endif
#if defined(__MMI_LANG_NORWEGIAN__)
	SSC_NORWEGIAN, 
#endif
#if defined(__MMI_LANG_SWEDISH__)
	SSC_SWEDISH, 
#endif
#if defined(__MMI_LANG_CROATIAN__)
	SSC_CROATIAN, 
#endif
#if defined(__MMI_LANG_ROMANIAN__)
	SSC_ROMANIAN, 
#endif
#if defined(__MMI_LANG_SLOVENIAN__)
	SSC_SLOVENIAN, 
#endif
#if defined(__MMI_LANG_GREEK__)
	SSC_GREEK, 
#endif
#if defined (__MMI_LANG_HEBREW__)
	SSC_HEBREW, 
#endif
#if defined (__MMI_LANG_ARABIC__)
	SSC_ARABIC, 
#endif
#if defined (__MMI_LANG_PERSIAN__)
	SSC_PERSIAN, 
#endif
#if defined (__MMI_LANG_URDU__)
	SSC_URDU, 
#endif
#if defined (__MMI_LANG_HINDI__)
	SSC_HINDI, 
#endif
#if defined (__MMI_LANG_MARATHI__)
	SSC_MARATHI, 
#endif
#if defined (__MMI_LANG_TAMIL__)
	SSC_TAMIL, 
#endif
#if defined (__MMI_LANG_BENGALI__)
	SSC_BENGALI,
#endif
#if defined (__MMI_LANG_PUNJABI__)
	SSC_PUNJABI, 
#endif
#if defined (__MMI_LANG_TELUGU__)
	SSC_TELUGU, 
#endif
/* this feature add for __MMI_DSM_NEW_JSKY__, later will effect all */
#if defined (__MMI_LANG_SA_PORTUGUESE__)	//sky chenwei add for south American
	SSC_SA_PORTUGUESE, 
#endif
#if defined (__MMI_LANG_SA_SPANISH__)		//sky chenwei add for south American
	SSC_SA_SPANISH, 
#endif
/* this feature add for __MMI_DSM_NEW_JSKY__, later will effect all */
#if defined(__MMI_LANG_SM_CHINESE__)
	SSC_SCHINESE, 
#endif
};


static const int32 s_support_langs[] = {
#if defined(__MMI_LANG_ENGLISH__)		
	MR_ENGLISH,
#endif
#if defined(__MMI_LANG_TR_CHINESE__)		
	MR_TCHINESE,
#endif
#if defined(__MMI_LANG_SPANISH__)
	MR_SPANISH,
#endif
#if defined(__MMI_LANG_DANISH__)
	MR_DANISH,
#endif
#if defined(__MMI_LANG_POLISH__)
	MR_POLISH,
#endif
#if defined(__MMI_LANG_FRENCH__)
	MR_FRENCH,
#endif
#if defined(__MMI_LANG_GERMAN__)
	MR_GERMAN,
#endif
#if defined(__MMI_LANG_ITALIAN__)
	 MR_ITALIAN,
#endif
#if defined(__MMI_LANG_THAI__)
	MR_THAI,
#endif
#if defined(__MMI_LANG_RUSSIAN__)
	MR_RUSSIAN,
#endif
#if defined(__MMI_LANG_BULGARIAN__)
	MR_BULGARIAN,
#endif
#if defined(__MMI_LANG_UKRAINIAN__)
	MR_UKRAINIAN,
#endif
#if defined(__MMI_LANG_PORTUGUESE__)
	MR_PORTUGUESE,
#endif
#if defined(__MMI_LANG_TURKISH__)
	MR_TURKISH,
#endif
#if defined(__MMI_LANG_VIETNAMESE__)
	MR_VIETNAMESE,
#endif
#if defined(__MMI_LANG_INDONESIAN__)
	MR_INDONESIAN,
#endif
#if defined(__MMI_LANG_CZECH__)
	MR_CZECH,
#endif
#if defined(__MMI_LANG_MALAY__)
	MR_MALAY,
#endif
#if defined(__MMI_LANG_FINNISH__)
	MR_FINNISH,
#endif
#if defined(__MMI_LANG_HUNGARIAN__)
	MR_HUNGARIAN,
#endif
#if defined(__MMI_LANG_SLOVAK__)
	MR_SLOVAK,
#endif
#if defined(__MMI_LANG_DUTCH__)
	MR_DUTCH,
#endif
#if defined(__MMI_LANG_NORWEGIAN__)
	MR_NORWEGIAN,
#endif
#if defined(__MMI_LANG_SWEDISH__)
	MR_SWEDISH,
#endif
#if defined(__MMI_LANG_CROATIAN__)
	MR_CROATIAN,
#endif
#if defined(__MMI_LANG_ROMANIAN__)
	MR_ROMANIAN,
#endif
#if defined(__MMI_LANG_SLOVENIAN__)
	MR_SLOVENIAN,
#endif
#if defined(__MMI_LANG_GREEK__)
	MR_GREEK,
#endif
#if defined (__MMI_LANG_HEBREW__)
	MR_HEBREW,
#endif
#if defined (__MMI_LANG_ARABIC__)
	MR_ARABIC,
#endif
#if defined (__MMI_LANG_PERSIAN__)
	MR_PERSIAN,
#endif
#if defined (__MMI_LANG_URDU__)
	MR_URDU,
#endif
#if defined (__MMI_LANG_HINDI__)
	MR_HINDI,
#endif
#if defined (__MMI_LANG_MARATHI__)
	MR_MARATHI,
#endif
#if defined (__MMI_LANG_TAMIL__)
	MR_TAMIL,
#endif
#if defined (__MMI_LANG_BENGALI__)
	MR_BENGALI,
#endif
#if defined (__MMI_LANG_PUNJABI__)
	MR_PUNJABI,
#endif
#if defined (__MMI_LANG_TELUGU__)
	MR_TELUGU,
#endif
/* this feature add for __MMI_DSM_NEW_JSKY__, later will effect all */

#if defined (__MMI_LANG_SA_PORTUGUESE__)	//sky chenwei add for south American
	MR_PORTUGUESE,
#endif
#if defined (__MMI_LANG_SA_SPANISH__)		//sky chenwei add for south American
	MR_SPANISH,
#endif
/* this feature add for __MMI_DSM_NEW_JSKY__, later will effect all */
#if defined(__MMI_LANG_SM_CHINESE__)
	MR_CHINESE,
#endif
};


int32 mr_setting_get_cur_lang(int32 param)
{
	extern sLanguageDetails *gLanguageArray;
	extern U16 gCurrLangIndex;
 	int i;

	for(i = 0; i < sizeof(s_support_langs_ssc)/sizeof(s_support_langs_ssc[0]); i++)
	{
		if (strcmp((PS8)gLanguageArray[gCurrLangIndex].aLangSSC, s_support_langs_ssc[i]) == 0)
		{
			return s_support_langs[i];
	   	}
	}
	
	return MR_ENGLISH;
}


int32 mr_setting_get_support_langs(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	if(!output || !output_len){
		return MR_FAILED;
	}
	
	*output = (uint8*)s_support_langs;
	*output_len = sizeof(s_support_langs);
	return MR_SUCCESS;
}


#if (MTK_VERSION >= 0x0852)
#include "Wgui_include.h"
#undef hide_status_icon_bar
void hide_status_icon_bar(U8 status_bar_ID)
{
#if (MTK_VERSION >=0x09B0952)
	wgui_status_icon_bar_reset_display(status_bar_ID);
#else
	#if (MTK_VERSION > 0x0812)
	wgui_status_icon_hide_status_icon_bar(status_bar_ID);
	#else
	hide_status_icon_bar(status_bar_ID);
	#endif
#endif
}
#endif


int32 mr_setting_get_gmt_timezone(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
#ifdef __MMI_WC_TZ_SUPPORT__
	int32 CurrTZ;
	S16 tmpTimeZone;
	S16 error;
#ifdef __MMI_DUAL_CLOCK__
	S16 tmpFrmTZ;
#endif

	if(!output || !output_len || *output_len != sizeof(int32)){
		return MR_FAILED;
	}

	ReadValue(NVRAM_TIMEZONE, &tmpTimeZone, DS_SHORT, &error);		
	CurrTZ = tmpTimeZone;

#ifdef __MMI_DUAL_CLOCK__
	ReadValue(NVRAM_FRN_TIMEZONE, &tmpFrmTZ, DS_SHORT, &error);		
	CurrTZ = (FLOAT)tmpFrmTZ;
#endif /* __MMI_DUAL_CLOCK__ */

	(*(int32*)output) = CurrTZ;
	return MR_SUCCESS;
#else
	return MR_FAILED;
#endif
}


int32 mr_setting_set_datetime(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	MYTIME *pMytime = (MYTIME *)(input);

	if(pMytime == NULL)
		return MR_FAILED;
	
	mmi_dt_set_rtc_dt(pMytime);
	
	return MR_SUCCESS;
}


#ifdef __MR_CFG_FEATURE_HANDSETID_EX__
extern kal_char* release_verno(void) ;
int32 mr_setting_get_handsetID_ex(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	mr_userinfo usrinfo;
	char tmp[__MR_CFG_VAR_HANDSETID_EX_LENGHT_MAX__+1] = {0};
	if(!input || input_len < __MR_CFG_VAR_HANDSETID_EX_LENGHT_MAX__)
		return MR_FAILED;

	mr_getUserInfo(&usrinfo);
	#if 1//huangsunbo 20120106 部分服务器只能支持长度为32的扩展机型，添加长度限制
	if( strlen((char*)release_verno()) <= (__MR_CFG_VAR_HANDSETID_EX_LENGHT_MAX__ -10) )
	{
		strcpy(tmp,release_verno());
	}
	else
	{
		strncpy(tmp,release_verno(),__MR_CFG_VAR_HANDSETID_EX_LENGHT_MAX__ - 10 );
	}
	
	kal_snprintf((char*)input, input_len, "%s!%s", usrinfo.type, tmp);
	#else
	kal_snprintf((char*)input, input_len, "%s!%s", usrinfo.type, __MR_CFG_VAR_HANDSETID_EX__);
	#endif
	return MR_SUCCESS;
}
#endif

extern void mmi_imgview_get_storage_file_path(PS8 filepath);
int32 mr_setting_get_system_image_path(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	static WCHAR mr_camera_path[DSM_MAX_FILE_LEN] = {0};
	int len;
	WCHAR* tmp;

	MMI_ASSERT(output != NULL);
	
#if defined(__MMI_IMAGE_VIEWER__) || defined(__MMI_FILE_MANAGER__)
	mmi_imgview_get_storage_file_path((PS8)mr_camera_path);
	len = kal_wstrlen(mr_camera_path);
	if (mr_camera_path[len - 1] == '\\') mr_camera_path[len - 1] = 0;	
#else
	kal_wstrncat((WCHAR*)mr_camera_path, (const WCHAR*)"E:\\Image", DSM_MAX_FILE_LEN - 1);
#endif

	if(mr_camera_path[0] == MMI_SYSTEM_DRV)
	{
		mr_camera_path[0] = 'A';
	}
	else if(mr_camera_path[0] == MMI_PUBLIC_DRV)
	{
		if(MMI_PUBLIC_DRV == MMI_CARD_DRV)
		{
			mr_camera_path[0] = 'C';
		}
		else
		{
			mr_camera_path[0] = 'B';
		}
	}
	else
	{
		mr_camera_path[0] = 'C';
	}
	
	tmp = mr_camera_path;
	while(tmp = (WCHAR*)app_ucs2_strchr((kal_int8*)tmp, '\\'))
	{
		*tmp = '/';
		++tmp;
	}
	
	*output = (uint8*)mr_camera_path;	//*output = (uint8*)L"C:/Images";
	
	return MR_SUCCESS;
}

int32 mr_setting_image_encode(uint8* input, int32 input_len, uint8** output, int32* output_len, MR_PLAT_EX_CB *cb)
{
	mr_image_encode_info* info;
	GDI_RESULT ret = GDI_FAILED;
	WCHAR* path;
	WCHAR* tmp;

	info = (mr_image_encode_info*)input;

	path = OslMalloc(mr_str_wstrlen((char*)info->path) + 2);
	if (path == NULL)
		return MR_FAILED;

	path[0] = 0;
	app_ucs2_strcat((kal_int8*)path, (kal_int8*)info->path);

	if(path[0] == 'A'||path[0] == 'a')
	{
		path[0] = MMI_SYSTEM_DRV;
	}
	else if(path[0] == 'B'||path[0] == 'b')
	{
		path[0] = MMI_PUBLIC_DRV;
	}
	else
	{
		path[0] = MMI_CARD_DRV;
	}
	
	tmp = path;
	while(tmp = (WCHAR*)app_ucs2_strchr((kal_int8*)tmp, '/'))
	{
		*tmp = '\\';
		++tmp;
	}

	if (info->type == IMG_BMP)
	{
		ret = gdi_image_bmp_encode_file(info->w, info->h, GDI_COLOR_FORMAT_16, info->buf, (PS8)path);
	}
	else if (info->type == IMG_JPG)
	{
		mr_layer_create_info_t layer_info;
		mr_common_rsp_t* rsp;
		int32 len;

		layer_info.x = 0;
		layer_info.y = 0;
		layer_info.w = info->w;
		layer_info.h = info->h;
		layer_info.size = info->w * info->h * 2;
		layer_info.buffer = info->buf;
		
		if (mr_layer_create((uint8*)&layer_info, sizeof(layer_info), (uint8**)&rsp, &len, NULL) == MR_SUCCESS)
		{
			ret = gdi_image_encode_layer_to_jpeg(rsp->p1, (PS8)path);

			mr_layer_free(rsp->p1);
		}
	}

	OslMfree(path);
	
	if (ret == GDI_SUCCEED)
		return MR_SUCCESS;
	else
		return MR_FAILED;
}

void test_image_encode(void)
{
	mr_image_encode_info info;
	U8* buf;

	gdi_layer_get_buffer_ptr(&buf);
	
	info.w = 320;
	info.h = 480;
	info.buf = GDI_LAYERS[0].buf_ptr;
	info.path = (int16*)L"C:/test.jpg";
	info.type = IMG_JPG;

	mr_setting_image_encode((uint8*)&info, 0, 0, 0, NULL);
}

////////////////////////////////////////////////////////////////////////////////////////////////

MR_PLATEX_FUNC_BEGIN(setting)
	MR_PLATEX_FUNC_ENTRY_SUPPORT(MR_PLATEX_CODE_SETTING_SUPPORT, MR_SUCCESS)
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_GET_GMT_TZ, mr_setting_get_gmt_timezone)
	MR_PLATEX_FUNC_ENTRY(MR_PALTEX_CODE_SETTING_GET_SUPPORT_LANGS, mr_setting_get_support_langs)
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_WIFI_EXIST, mr_setting_wifi_exist)
#ifdef __MR_CFG_FEATURE_HANDSETID_EX__	
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_GET_HANDSETID_EX, mr_setting_get_handsetID_ex)
#endif

	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_GET_SYSTEM_IMAGE_PATH, mr_setting_get_system_image_path)
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_IMAGE_ENCODE, mr_setting_image_encode)
	
#ifdef __MR_CFG_SET_SMS_STATUS__
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_SMS_SET_STATUS, mr_sms_set_sms_status)
#endif
/* 52_xsgrz_patch begin */
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_CONFIG_SAMPLING_PERIOD, mr_app_config_sampling_period)
	MR_PLATEX_FUNC_ENTRY(MR_PLATEX_CODE_SETTING_CONFIG_MOVE_OFFSET, mr_app_config_move_offset)
/* 52_xsgrz_patch end */
MR_PLATEX_FUNC_END()

#endif

